package baseCodes.ClazzLoader;

import sun.misc.Launcher;
import java.net.URL;

/**
 * 这个是打印各个ClassLoader的情况
 */
public class TestJDKClassLoader {

    public static void main(String[] args) {
        System.out.println(String.class.getClassLoader());
        System.out.println(java.sql.DriverManager.class.getClassLoader());
        System.out.println(TestJDKClassLoader.class.getClassLoader());

        System.out.println("-----------------------------");

        ClassLoader appClassLoader = ClassLoader.getSystemClassLoader();
        ClassLoader extClassLoader = appClassLoader.getParent();
        ClassLoader classLoader = extClassLoader.getParent();
        System.out.println("Bootstrap Loader: "+classLoader);
        System.out.println("Ext Loader: "+extClassLoader);
        System.out.println("App Loader: "+appClassLoader);

        System.out.println("-----------------------------");

        System.out.println("BootStrap Loader下载以下的文件: ");
        URL[] urLs = Launcher.getBootstrapClassPath().getURLs();
        for (URL urL : urLs) {
            System.out.println(urL);
        }
    }

}
